package com.fenghen.controller;

import com.fenghen.dto.ProductStockDTO;
import com.fenghen.service.impl.SeckillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/seckill")
public class SeckillController {

    @Autowired
    private SeckillService seckillService;

    @PostMapping("/productId")
    public String seckill(@RequestBody ProductStockDTO productStockDTO) {
        try {
            seckillService.seckill(productStockDTO.getProductId());
            return "秒杀成功";
        } catch (Exception e) {
            return "秒杀失败: " + e.getMessage();
        }
    }
}
